//
//  HYReleaseSelectButton.m
//  HaiYue
//
//  Created by skyline on 2018/1/23.
//  Copyright © 2018年 skyline. All rights reserved.
//

#import "HYReleaseSelectButton.h"
@interface HYReleaseSelectButton()
@property (nonatomic, strong) HYLabel *titleLBL;
@end
@implementation HYReleaseSelectButton
- (instancetype)initWithTitle:(NSString *)title
{
    self = [super init];
    if (self)
    {
        _title = title;
        self.titleLBL.text = title;
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (HYLabel *)titleLBL
{
    if (!_titleLBL)
    {
       _titleLBL = [[HYLabel alloc] initWithText:@"" textColor:TEXT_BLACK_COLOR textFont:[UIFont systemFontOfSize:DefaultFont]];
        [self addSubview:_titleLBL];
        [_titleLBL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).with.offset(GAP);
            make.centerY.equalTo(self);
        }];
    }
    return _titleLBL;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self sendActionsForControlEvents:UIControlEventTouchUpInside];
    self.backgroundColor = [UIColor lightGrayColor];
    self.titleLBL.textColor = [UIColor whiteColor];
}

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [super touchesEnded:touches withEvent:event];
    self.backgroundColor = [UIColor whiteColor];
    self.titleLBL.textColor = TEXT_BLACK_COLOR;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
